<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body>

  <form class="layui-form" action="">
  		
  	 <!-- 第一行，文章标题 -->
	  <div class="layui-form-item">
	    <label class="layui-form-label">文章标题</label>
	    <div class="layui-input-block">
	      <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
	    </div>
	  </div>
	  
	  <!-- 富文本编辑器 -->
	  <div class="layui-form-item">
	    <label class="layui-form-label">文章内容</label>
	    <div class="layui-input-block">
	     <textarea id="demo" style="display: none;"></textarea>
	    </div>
	  </div>
	  
	  <!-- 下拉框 -->
	 <div class="layui-form-item">
	    <div class="layui-inline">
	      <label class="layui-form-label">文章分类</label>
	      <div class="layui-input-inline">
	        <select name="category">
	             <option value="">选择分类</option>
		          <option value="1">java</option>
		          <option value="2">c++</option>
		          <option value="3">web</option>
		          <option value="4">db</option>
		          <option value="5">python</option>
	        </select>
	      </div>
	    </div>
  	</div>
  	
  	<!-- 表单提交 -->
  	 <div class="layui-form-item">
	    <div class="layui-input-block">
	      <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
	      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
	    </div>
  	</div>
	  
  </form>
  
 <script type="text/javascript" src="../layui/layui.js"></script>
 
 <script>
 
 	layui.use(['layedit','form'],function(){
 	
 		var layedit = layui.layedit;
 		var form = layui.form;
		var index = layedit.build('demo'); //建立编辑器
		
		//用layui内置的jquery
		var $ = layui.$;
		
		  //监听提交
		  form.on('submit(demo1)', function(data){
			  
			console.log(data.field);//layui中的真正属性值，请求参数
			
			console.log(data);//lyaui中的data，封装了很多属性
			
			data.field.content = layedit.getContent(index);
			  
		   	$.get("../getForm",data.field,function(data){
		   		console.log(data)//回调函数中的data，响应参数
		   	})
			
		    return false;
		  });

 		});
 
 </script>

</body>
</html>